//
//  HouseInforCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/16.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "HouseInforCell.h"

@interface HouseInforCell ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *middleLabel;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@property (weak, nonatomic) IBOutlet UILabel *markLabelOne;
@property (weak, nonatomic) IBOutlet UILabel *markLabelTwo;
@property (weak, nonatomic) IBOutlet UILabel *markLabelThree;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;

@end

@implementation HouseInforCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = lineGray;
    
    self.topLabel.font = MYFONT(17);
    
    self.middleLabel.font = MYFONT(15);
    
    self.middleLabel.textColor = darkGray;
    
    self.priceLabel.font = MYFONT(17);
    
    self.priceLabel.textColor = [UIColor orangeColor];
    
    self.markLabelOne.font = MYFONT(13);
    
    self.markLabelTwo.font = MYFONT(13);
    
    self.markLabelThree.font = MYFONT(13);
    
    self.markLabelThree.textColor = colorWith(26, 90, 198);
    self.markLabelTwo.textColor = colorWith(26, 90, 198);
    self.markLabelOne.textColor = colorWith(26, 90, 198);
    
    self.markLabelThree.backgroundColor = colorWith(228, 244, 253);
    self.markLabelTwo.backgroundColor = colorWith(228, 244, 253);
    self.markLabelOne.backgroundColor = colorWith(228, 244, 253);
    
    self.markLabelThree.layer.cornerRadius = 5;
    self.markLabelTwo.layer.cornerRadius = 5;
    self.markLabelOne.layer.cornerRadius = 5;
    
    self.markLabelThree.layer.masksToBounds = YES;
    self.markLabelTwo.layer.masksToBounds = YES;
    self.markLabelOne.layer.masksToBounds = YES;



    self.bottomMargin.constant = 0;
    
    
    
    // Initialization code
}


- (void)setModel:(HomeSubModel *)model{
    _model = model;
    
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:_model.house_pic] placeholderImage:nil];
    
    self.topLabel.text = [NSString stringWithFormat:@"%@%@",_model.house_name,_model.apartment];
    
    self.middleLabel.text = [NSString stringWithFormat:@"%@ | %@ | %@",_model.apartment,_model.house_area,_model.house_name];
    
    self.priceLabel.text = [NSString stringWithFormat:@"%@P",_model.house_price];
    
    if ([_model.house_tag containsString:@";"]) {
        
        NSArray *arry = [_model.house_tag componentsSeparatedByString:@";"];
        
        if (arry.count == 2) {
            self.markLabelOne.hidden = NO;
            self.markLabelTwo.hidden = NO;
            self.markLabelThree.hidden = YES;
            self.markLabelOne.text = [NSString stringWithFormat:@" %@ ",arry.firstObject];
            self.markLabelTwo.text = [NSString stringWithFormat:@" %@ ",arry.lastObject];

        } else {
            self.markLabelOne.hidden = NO;
            self.markLabelTwo.hidden = NO;
            self.markLabelThree.hidden = NO;
            self.markLabelOne.text = [NSString stringWithFormat:@" %@ ",arry.firstObject];
            self.markLabelTwo.text = [NSString stringWithFormat:@" %@ ",arry[1]];
            self.markLabelThree.text = [NSString stringWithFormat:@" %@ ",arry.lastObject];
        }
    } else {
        self.markLabelOne.text = [NSString stringWithFormat:@" %@ ",_model.house_tag];
        self.markLabelOne.hidden = NO;
        self.markLabelTwo.hidden = YES;
        self.markLabelThree.hidden = YES;
    }
    
   

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
